//---------------------------------------------- // Purpose: Demonstrate recursive grammars // Author: John Gauch //---------------------------------------------- #include using namespace std; //---------------------------------------------- string ParseInt(const string Input, const int pos) { if ((pos < 0) || (pos >= int(Input.length()))) return ""; else if ((Input[pos] < '0') || (Input[pos] > '9')) return ""; else return (Input[pos] + ParseInt(Input, pos + 1)); } //---------------------------------------------- string ParseFloat(const string Input, const int pos) { // ADD HERE return ""; } //---------------------------------------------- int main() { string input = "123.456hello"; cout << "Input = " << input << endl; cout << "ParseInt = " << ParseInt(input, 0) << endl; cout << "ParseFloat = " << ParseFloat(input, 0) << endl; }